﻿using System;

namespace Malu.WebTemplates
{
    public partial class BaseAuthenticationPage : Wicresoft.Framework.Authentication.BasePage
    {


        public BaseAuthenticationPage()
        {
            //
            // TODO: Add constructor logic here
            //
        }

        #region List部分属性

        public Pager Pager
        {
            get
            {
                if (this.Master is ListMaster)
                {
                    return (this.Master as ListMaster).Pager;
                }
                return null;
            }
        }

        public bool ShowPager
        {
            get
            {
                if (this.Master is ListMaster)
                {
                    return (this.Master as ListMaster).ShowPager;
                }
                return false;
            }
            set
            {
                if (this.Master is ListMaster)
                {
                    (this.Master as ListMaster).ShowPager = value;
                }
            }
        }

        public Order Order
        {
            get
            {
                if (this.Master is ListMaster)
                {
                    return (this.Master as ListMaster).Order;
                }
                return null;
            }
        }

        public string DefaultLayout
        {
            get
            {
                if (this.Master is ListMaster)
                {
                    return (this.Master as ListMaster).DefaultLayout;
                }
                return null;
            }
            set
            {
                if (this.Master is ListMaster)
                {
                    (this.Master as ListMaster).DefaultLayout = value;
                }
            }
        }

        public bool ShowLRLayoutButton
        {
            get
            {
                if (this.Master is ListMaster)
                {
                    return (this.Master as ListMaster).ShowLRLayoutButton;
                }
                return true;
            }
            set
            {
                if (this.Master is ListMaster)
                {
                    (this.Master as ListMaster).ShowLRLayoutButton = value;
                }
            }
        }

        public bool ShowUDLayoutButton
        {
            get
            {
                if (this.Master is ListMaster)
                {
                    return (this.Master as ListMaster).ShowUDLayoutButton;
                }
                return true;
            }
            set
            {
                if (this.Master is ListMaster)
                {
                    (this.Master as ListMaster).ShowUDLayoutButton = value;
                }
            }
        }

        public bool ShowSimpleLayoutButton
        {
            get
            {
                if (this.Master is ListMaster)
                {
                    return (this.Master as ListMaster).ShowSimpleLayoutButton;
                }
                return true;
            }
            set
            {
                if (this.Master is ListMaster)
                {
                    (this.Master as ListMaster).ShowSimpleLayoutButton = value;
                }
            }
        }

        public bool ShowAdvancedSearch
        {
            get
            {
                if (this.Master is ListMaster)
                {
                    return (this.Master as ListMaster).ShowAdvancedSearch;
                }
                return true;
            }
            set
            {
                if (this.Master is ListMaster)
                {
                    (this.Master as ListMaster).ShowAdvancedSearch = value;
                }
            }
        }

        public bool ShowScrollDiv
        {
            get
            {
                if (this.Master is ListMaster)
                {
                    return (this.Master as ListMaster).ShowScrollDiv;
                }
                return true;
            }
            set
            {
                if (this.Master is ListMaster)
                {
                    (this.Master as ListMaster).ShowScrollDiv = value;
                }
            }
        }
        #endregion

        #region Detail部分属性

        public bool UseTabber
        {
            get
            {
                if (this.Master is DetailMaster)
                {
                    return (this.Master as DetailMaster).UseTabber;
                }
                return true;
            }
            set
            {
                if (this.Master is DetailMaster)
                {
                    (this.Master as DetailMaster).UseTabber = value;
                }
            }
        }
        #endregion


        protected override void OnInit(EventArgs e)
        {
            if (this.Pager != null)
                this.Pager.PageChanged += new PageChangeEventHandler(Pager_PageChanged);

            if (this.Order != null)
                this.Order.OrderChanged += new OrderChangeEventHandler(Order_OrderChanged);

            base.OnInit(e);
        }

        protected virtual void Order_OrderChanged(object sender, EventArgs e)
        {
        }

        protected virtual void Pager_PageChanged(object sender, EventArgs e)
        {
        }



        //#region 压缩页面

        //protected override void SavePageStateToPersistenceMedium(object state)
        //{
        //    LosFormatter formatter = new LosFormatter();
        //    StringWriter writer = new StringWriter();
        //    formatter.Serialize(writer, state);
        //    string viewState = writer.ToString();
        //    byte[] data = Convert.FromBase64String(viewState);
        //    byte[] compressedData = Util.Utility.Compress(data);
        //    string str = Convert.ToBase64String(compressedData);
        //    ClientScript.RegisterHiddenField("__CBNVIEWSTATE", str);
        //}
        //protected override object LoadPageStateFromPersistenceMedium()
        //{
        //    string viewstate = Request.Form["__CBNVIEWSTATE"];
        //    byte[] data = Convert.FromBase64String(viewstate);
        //    byte[] uncompressedData =
        //    Util.Utility.Decompress(data);
        //    string str = Convert.ToBase64String(uncompressedData);
        //    LosFormatter formatter = new LosFormatter();
        //    return formatter.Deserialize(str);
        //}
        //#endregion

    }
}